package org.example;

import com.example.bean.Product;
import com.example.bean.Student;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class Main {
    public static void main(String[] args) {
        // 加载Spring配置文件
        ApplicationContext context = new ClassPathXmlApplicationContext("spring.xml");

        // 关键：获取Bean的ID必须与spring.xml中配置的id一致
        // 例如：如果XML中是id="product"，这里就用"product"
        Product product = context.getBean("product", Product.class);
        Student student = context.getBean("student", Student.class);

        System.out.println("Product: " + product);
        System.out.println("Student: " + student);
    }
}

